package com.example.controller;

import com.example.pojo.Role;
import com.example.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedList;
import java.util.List;

/**
 * @program: springboot_course
 * @description:
 * @author: ChenZhiXiang
 * @create: 2019-07-19 14:30
 **/
@RestController
@RequestMapping("role")
public class RoleController {

    @Autowired
    private MongoTemplate template;

    @PostMapping("/add")
    public Object add(){
//        Role role = new Role(1,"无极剑圣","易大师，无极之道");
//        Object obj = template.insert(role);
//        return obj;

//        List<Role> list = new LinkedList<>();
//        Role role1 = new Role(2,"无双剑姬","我是一个用剑的艺术家（画了个提莫）没有骗你吧~");
//        Role role2 = new Role(3,"疾风剑豪","死亡如风,常伴吾身");
//        list.add(role1);
//        list.add(role2);
//        Object o = template.insert(list,Role.class);
//        return o;

//        Role role = new Role(4,"放逐之刃","刀剑映出了战士的心。而我的心，漆黑且残破");
//        Object o = template.insert(role,"hero_role");
//        return o;

        Role role = new Role(4,"诺克萨斯之手","他们将后悔与我为敌。");
        User user = new User(5L,"您不好哦","专杀达威",null);
        List<Object> list = new LinkedList<>();
        list.add(role);
        list.add(user);
        return template.insertAll(list);

    }


}
